package com.seocoo.worker.friend.adapter;

import android.widget.EditText;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.seocoo.worker.R;
import com.seocoo.worker.base.widget.BaseStarOrangeView;
import com.seocoo.worker.friend.req.ReqFriendEvaluateParam;
import com.seocoo.worker.order.entity.RspOrderIWorkmateInfo;

import java.util.ArrayList;

/**
 * author : Ssp
 * e-mail : 981297079@qq.com
 * date   : 2020/3/720:46
 * desc   : 评价工友
 * version: 1.0
 */
public class FriendEvaluateAdapter extends BaseQuickAdapter<RspOrderIWorkmateInfo, BaseViewHolder> {

    public FriendEvaluateAdapter() {
        super(R.layout.friend_evaluate_item);
    }

    @Override
    protected void convert(BaseViewHolder helper, RspOrderIWorkmateInfo item) {
        helper.setText(R.id.tvContent, item.getRealName() + "-" + item.getPhoneNumber());
    }

    /**
     * 获取评价
     */
    public ArrayList<ReqFriendEvaluateParam> getAllEvaluate(String orderId) {
        ArrayList<ReqFriendEvaluateParam> list = new ArrayList<>();
        if (mData.size() > 0) {
            for (int i = 0; i < mData.size(); i++) {
                ReqFriendEvaluateParam param = new ReqFriendEvaluateParam();
                param.setOrderId(orderId);
                RspOrderIWorkmateInfo rspWorkers = mData.get(i);
                param.setUserId(rspWorkers.getUserId());
                EditText et_evaluate = (EditText) getViewByPosition(i, R.id.et_evaluate);
                if (et_evaluate != null) {
                    String text = et_evaluate.getText().toString();
                    param.setContent(text);
                }
                BaseStarOrangeView bsovStar = (BaseStarOrangeView) getViewByPosition(i, R.id.bsovStar);
                if (et_evaluate != null) {
                    assert bsovStar != null;
                    int star = bsovStar.getStar();
                    param.setStarCount(String.valueOf(star));
                }
                list.add(param);
            }

        }
        return list;
    }
}
